package cmms.session;

import java.util.List;

import fab.web.mvc.AbstractUserSession;

public class UserSession extends AbstractUserSession {
	private short accountType;
	private String userName;
	private short userState;
	private boolean isPasswordLogin;

	private String key;

	private String loginId;
	private long logoIndex;
	private String nickName;
	private long personId;
	private String personName;
	private String sessionId;

	private  String userMail;
	private String userPhone;
	private String shopCode;

	private long shopId;

	private short shopManageDownLevel;

	private String shopName;
	private String userLoginName;

	private long userLinkId;
	// 签名
	private String userIdiograph;

	public String getUserIdiograph() {
		return userIdiograph;
	}

	public void setUserIdiograph(String userIdiograph) {
		this.userIdiograph = userIdiograph;
	}

	public void addRoles(List<Long> roles) {
		this.allRoles = roles;
	}

	public short getAccountType() {
		return accountType;
	}

	public String getKey() {
		return key;
	}

	public String getLoginId() {
		return loginId;
	}

	public long getLogoIndex() {
		return logoIndex;
	}

	public String getNickName() {
		return nickName;
	}

	public long getPersonId() {
		return personId;
	}

	public String getPersonName() {
		return personName;
	}

	public String getSessionId() {
		return sessionId;
	}

	public String getShopCode() {
		return shopCode;
	}

	public long getShopId() {
		return shopId;
	}

	public short getShopManageDownLevel() {
		return shopManageDownLevel;
	}

	public String getShopName() {
		return shopName;
	}

	public long getUserLinkId() {

		return userLinkId;
	}
	
	private short childShopState = -1;
	private short parentShopState = -1;

	public boolean hasPrivileges(int actionPrivilegeValue) {
		boolean isPrivilege = false;
		for (Long role : getAllRoles()) {
			if ((actionPrivilegeValue & role) == role) {
				isPrivilege = true;
				break;
			}
		}
		return isPrivilege;
	}

	public boolean isPasswordLogin() {
		return isPasswordLogin;
	}

	public void setAccountType(short accountType) {
		this.accountType = accountType;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public void setLoginId(String loginId) {
		this.loginId = loginId;
	}

	public void setLogoIndex(long logoIndex) {
		this.logoIndex = logoIndex;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	public void setPasswordLogin(boolean isPasswordLogin) {
		this.isPasswordLogin = isPasswordLogin;
	}

	public void setPersonId(long personId) {
		this.personId = personId;
	}

	public void setPersonName(String personName) {
		this.personName = personName;
	}

	public void setSessionId(String sessionId) {
		this.sessionId = sessionId;
	}

	public void setShopCode(String shopCode) {
		this.shopCode = shopCode;
	}

	public void setShopId(long shopId) {
		this.shopId = shopId;
	}

	public void setShopManageDownLevel(short shopManageDownLevel) {
		this.shopManageDownLevel = shopManageDownLevel;
	}

	public void setShopName(String shopName) {
		this.shopName = shopName;
	}

	public void setUserLinkId(long userLinkId) {
		this.userLinkId = userLinkId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getUserLoginName() {
		return userLoginName;
	}

	public void setUserLoginName(String userLoginName) {
		this.userLoginName = userLoginName;
	}

	public short getUserState() {
		return userState;
	}

	public void setUserState(short userState) {
		this.userState = userState;
	}

	public String getUserMail() {
		return userMail;
	}

	public void setUserMail(String userMail) {
		this.userMail = userMail;
	}

	public String getUserPhone() {
		return userPhone;
	}

	public void setUserPhone(String userPhone) {
		this.userPhone = userPhone;
	}

	public short getChildShopState() {
		return childShopState;
	}

	public void setChildShopState(short childShopState) {
		this.childShopState = childShopState;
	}

	public short getParentShopState() {
		return parentShopState;
	}

	public void setParentShopState(short parentShopState) {
		this.parentShopState = parentShopState;
	}

}
